From edbc74eb40c383f68f649a8a4a3e166599861c3f Mon Sep 17 00:00:00 2001 From: "rac61@labyrinth.cl.cam.ac.uk" Date: Wed, 9 Jul 2003 09:17:42 +0000 Subject: [PATCH] bitkeeper revision 1.304.1.3 (3f0bddb6Ch28VohngLcKCCbcXEwq2Q) Prune unneeded bits of old vdmanager code; main and parser. All their functionality has been liberated. =) --- .rootkeys | 2 - .../uk/ac/cam/cl/xeno/xenctl/Main.java.orig | 35 -- .../src/uk/ac/cam/cl/xeno/xenctl/Parser.java | 446 ------------------ 3 files changed, 483 deletions(-) delete mode 100644 tools/control/src/uk/ac/cam/cl/xeno/xenctl/Main.java.orig delete mode 100644 tools/control/src/uk/ac/cam/cl/xeno/xenctl/Parser.java diff --git a/.rootkeys b/.rootkeys index b51b430d96..09528b586d 100644 --- a/.rootkeys +++ b/.rootkeys @@ -64,8 +64,6 @@ 3ec41f7dKX9YpwrfH7BZ7BogyWqqLA tools/control/src/org/xenoserver/control/VirtualDiskManager.java 3ec41f7dUPpYTwYL5QVpRBv6PLKPrg tools/control/src/org/xenoserver/control/XML.java 3ec41f7d7Try-2zmfnpaALwJjY0GCA tools/control/src/org/xenoserver/control/XMLHelper.java -3ec41f7civcv4mQiYK0DeX9Zvsxhrw tools/control/src/uk/ac/cam/cl/xeno/xenctl/Main.java.orig -3ec41f7d3-xTeoVJBJqWqxVfU-ANoQ tools/control/src/uk/ac/cam/cl/xeno/xenctl/Parser.java 3ec41f7dOVZgjP4sQS6vjuBnExdlMQ tools/control/src/uk/ac/cam/cl/xeno/xenctl/RootBean.java 3ec41f7dvPdszb0frNEkMnEdJUBVjA tools/control/src/uk/ac/cam/cl/xeno/xenctl/SystemConfigurationBean.java 3ec41f7dO6IuKGGLG4VRUhMDmkTn5g tools/control/web/WEB-INF/web.xml diff --git a/tools/control/src/uk/ac/cam/cl/xeno/xenctl/Main.java.orig b/tools/control/src/uk/ac/cam/cl/xeno/xenctl/Main.java.orig deleted file mode 100644 index 2110521bcb..0000000000 --- a/tools/control/src/uk/ac/cam/cl/xeno/xenctl/Main.java.orig +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Main.java - * 03.03.26 aho creation - */ - -package uk.ac.cam.cl.xeno.vdmanager; - -import java.util.Date; - -public class -Main -{ - static String state_filename_in = "/var/lib/xen/vdstate.xml"; - static String state_filename_out = "/var/lib/xen/vdstate.xml"; - static String partition_filename = "/proc/partitions"; - - void - go (String[] argv) - { - PartitionManager pm = new PartitionManager(partition_filename); - VirtualDiskManager vdm = new VirtualDiskManager();; - Parser parser = new Parser(pm, vdm); - - XML.load_state(pm, vdm, state_filename_in); - parser.parse_main(argv); - XML.dump_state(pm, vdm, state_filename_out); - } - - public static void - main (String[] argv) - { - Main foo = new Main(); - foo.go(argv); - } -} diff --git a/tools/control/src/uk/ac/cam/cl/xeno/xenctl/Parser.java b/tools/control/src/uk/ac/cam/cl/xeno/xenctl/Parser.java deleted file mode 100644 index a1459a1ba1..0000000000 --- a/tools/control/src/uk/ac/cam/cl/xeno/xenctl/Parser.java +++ /dev/null @@ -1,446 +0,0 @@ -/* - * Parser.java - * 03.03.27 aho creation - */ - -package uk.ac.cam.cl.xeno.xenctl; - -import java.io.BufferedReader; -import java.io.FileReader; -import java.io.InputStreamReader; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.util.StringTokenizer; -import java.util.Vector; -import java.util.Date; - -public class -Parser -{ - static String prompt = "vdmanager> "; - static String default_addpartition_chunksize = "104857600"; /* 100M */ - static int default_sector_size = 512; - - PartitionManager pm; - VirtualDiskManager vdm; - - Parser (PartitionManager pm, VirtualDiskManager vdm) - { - this.pm = pm; - this.vdm = vdm; - } - - void - parse_main (String[] argv) - { - if (argv.length == 0) - { - parse_input(null); - } - else - { - parse_commandline(argv); - } - } - - void - parse_input (String filename) - { - String line; - BufferedReader in; - - if (filename != null) - { - try - { - in = new BufferedReader(new FileReader(filename)); - } - catch (FileNotFoundException fnfe) - { - System.err.println (fnfe); - return; - } - } - else - { - in = new BufferedReader(new InputStreamReader(System.in)); - } - - try - { - if (filename == null) - { - System.out.print (prompt); - } - line = in.readLine(); - while (line != null) - { - StringTokenizer st = new StringTokenizer(line); - Vector v = new Vector(); - - while (st.hasMoreTokens()) - { - v.add(st.nextToken()); - } - - if (parse_commandline((String[]) v.toArray(new String[v.size()]))) - { - return; - } - - if (filename == null) - { - System.out.print (prompt); - } - line = in.readLine(); - } - } - catch (IOException ioe) - { - System.err.println(ioe); - } - - if (filename == null) - { - System.out.println (""); - } - return; - } - - boolean - parse_commandline (String[] commands) - { - if (commands.length == 0) - { - return false; - } - - String keyword = commands[0].toLowerCase(); - if (keyword.equals("file")) - { - if (commands.length < 2) - { - System.out.println ("file [filename]"); - return false; - } - for (int i = 1; i < commands.length; i++) - { - System.out.println ("file " + commands[i]); - parse_input(commands[i]); - } - } - else if (keyword.equals("show")) - { - parse_show(commands); - } - else if (keyword.equals("addpartition")) - { - parse_addpartition(commands); - } - else if (keyword.equals("vdcreate")) - { - parse_vdcreate(commands); - } - else if (keyword.equals("vddelete")) - { - parse_vddelete(commands); - } - else if (keyword.equals("vdrefresh")) - { - parse_vdrefresh(commands); - } - else if (keyword.equals("vbdcreate")) - { - parse_vbdcreate(commands); - } - else if (keyword.equals("vbddelete")) - { - parse_vbddelete(commands); - } - else if (keyword.equals("vbdflush")) - { - vdm.flush_virtual_block_devices(); - } - else if (keyword.equals("load")) - { - if (commands.length < 2) - { - System.out.println ("load "); - return false; - } - XML.load_state (pm, vdm, commands[1]); - } - else if (keyword.equals("save")) - { - if (commands.length < 2) - { - System.out.println ("save "); - return false; - } - XML.dump_state (pm, vdm, commands[1]); - } - else if (keyword.equals("help") || - keyword.equals("?")) - { - parse_help(); - } - else if (keyword.equals("exit") || - keyword.equals("quit")) - { - return true; - } - else - { - System.out.println ("unknown command [" + commands[0] + "]. " + - "try \"help\""); - } - return false; - } - - void - parse_vdcreate (String[] commands) - { - VirtualDisk vd; - - if (commands.length < 4) - { - System.out.println ("vdcreate name size expiry"); - return; - } - - vd = vdm.create_virtual_disk(commands[1], - Library.parse_size(commands[2]) / default_sector_size, - new Date()); - - System.out.println ("Virtual Disk created with key: " + vd.get_key()); - } - - void - parse_vddelete (String[] commands) - { - if (commands.length < 2) - { - System.out.println ("vddelete key"); - return; - } - - vdm.delete_virtual_disk(commands[1]); - } - - void - parse_vdrefresh (String[] commands) - { - if (commands.length < 3) - { - System.out.println ("vdrefresh key expiry"); - return; - } - - vdm.refresh_virtual_disk(commands[1], - new Date()); - } - - void - parse_vbdcreate (String[] commands) - { - VirtualDisk vd; - VirtualBlockDevice vbd; - - if (commands.length < 4) - { - System.out.println ("vbdcreate "); - return; - } - - if (commands[1].startsWith("sd") || - commands[1].startsWith("hd")) - { - /* - * this is a gross hack to allow you to create a virtual block - * device that maps directly to a physical partition - */ - - /* find the appropriate partition */ - Partition partition = pm.get_partition(commands[1]); - if (partition == null) - { - System.out.println ("vbdcreate error: couldn't find partition \"" + - commands[1] + "\""); - return; - } - - /* create a virtual disk */ - vd = new VirtualDisk("vbd:" + commands[1]); - vd.add_new_partition(partition, partition.nr_sects); - - - /* display result */ - System.out.print("domain:" + commands[2] + " "); - if (commands.length == 4) - { - System.out.print ("rw "); - } - else - { - System.out.print(commands[4] + " "); - } - System.out.print("segment:" + commands[3] + " "); - System.out.print(vd.dump_xen()); - System.out.println(""); - - return; - } - - if (commands.length == 4) - { - vbd = - vdm.create_virtual_block_device(commands[1], - Integer.decode(commands[2]).intValue(), - Integer.decode(commands[3]).intValue(), - "rw"); - } - else - { - vbd = - vdm.create_virtual_block_device(commands[1], - Integer.decode(commands[2]).intValue(), - Integer.decode(commands[3]).intValue(), - commands[4]); - } - - /* display commandline to user */ - { - vd = vdm.get_virtual_disk_key(commands[1]); - System.out.println ("\n" + vd.dump_xen(vbd) + "\n"); - } - } - - void - parse_vbddelete (String[] commands) - { - if (commands.length < 3) - { - System.out.println ("vbddelete "); - return; - } - - vdm.delete_virtual_block_device(Integer.decode(commands[1]).intValue(), - Integer.decode(commands[2]).intValue()); - } - - static String show_helptxt = "show "; - void - parse_show (String[] commands) - { - String subword; - - if (commands.length < 2) - { - System.out.println (show_helptxt); - return; - } - - subword = commands[1].toLowerCase(); - if (subword.equals("partition") || - subword.equals("partitions")) - { - System.out.println(pm.dump(true)); - } - else if (subword.equals("vd")) - { - String text; - - if (commands.length < 3) - { - System.out.println(vdm.dump_virtualdisks()); - return; - } - text = vdm.dump_virtualdisk(Integer.decode(commands[2]).intValue()); - if (text == null) - { - System.out.println("show vd error: invalid virtual disk number"); - } - else - { - System.out.println(text); - } - } - else if (subword.equals("vbd")) - { - System.out.println(vdm.dump_virtualblockdevices()); - } - else if (subword.equals("free")) - { - System.out.println(vdm.dump_free()); - } - else - { - System.out.println (show_helptxt); - return; - } - } - - void - parse_addpartition(String[] commands) - { - String chunksize = default_addpartition_chunksize; - - if (commands.length > 3 || commands.length < 2) - { - System.out.println ("addpartition [chunksize]"); - return; - } - if (commands.length == 3) - { - chunksize = commands[2]; - } - - System.out.println ("add partition " + commands[1] + " " + chunksize); - - vdm.add_xeno_partition(pm.get_partition(Integer.parseInt(commands[1])), - Library.parse_size(chunksize)/default_sector_size); - pm.add_xeno_partition(pm.get_partition(Integer.parseInt(commands[1]))); - } - - void - parse_help() - { - System.out.println ("file " + - "read the contents of a file as input to vdmanager"); - System.out.println ("addpartition [chunksize]"); - System.out.println (" " + - "add a partition as a xeno partition"); - System.out.println ("vdcreate "); - System.out.println (" " + - "create a new virtual disk"); - System.out.println ("vddelete " + - "delete a virtual disk"); - System.out.println ("vdrefresh "); - System.out.println (" " + - "reset virtual disk expiry"); - System.out.println ("vbdcreate [rw|ro]"); - System.out.println (" " + - "create a new virtual block device"); - System.out.println ("vbddelete "); - System.out.println (" " + - "delete a new virtual block device"); - System.out.println ("vbdflush " + - "remove all virtual block devices"); - System.out.println ("show partitions " + - "display a complete list of disk partitions"); - System.out.println ("show vd " + - "display virtual disk information"); - System.out.println ("show vbd " + - "display virtual virtual block device list"); - System.out.println ("show free " + - "display details about unallocated space"); - System.out.println ("load " + - "load new state from file"); - System.out.println ("save " + - "save state to file"); - System.out.println ("help " + - "display this help message"); - System.out.println ("quit " + - "exit"); - } -} -- 2.30.2